@isTest
private class SalesAreaBudgetExecSheetTest{
    static testMethod void testMethod1(){
        SalesAreaBudgetExecSheetTest.createBaseInfo();
           
        SalesAreaBudgetExecSheetSchedulable sc = new SalesAreaBudgetExecSheetSchedulable();
        String fmt = '0 10 0 1-31 1-12 ? 2017-2098';//每天执行一次
        System.schedule('每天刷新区域预算执行明细'+Datetime.now().format('yyyyMMddHHmmss'), fmt, sc);       

    }
    static testMethod void testMethod2(){
         SalesAreaBudgetExecSheetTest.createBaseInfo();
         SalesAreaBudgetExecSheetBatch batch = new SalesAreaBudgetExecSheetBatch();
        
         Test.startTest();
         String fmt = '0 10 0 1-31 1-12 ? 2017-2098';//每天执行一次
         String jobId = System.schedule('testBasicScheduledApex',fmt,
                new SalesAreaBudgetExecSheetSchedulable());
         System.debug('==>'+jobId);
         CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered,NextFireTime
                            FROM CronTrigger WHERE id = :jobId];
            
         System.assertEquals(fmt,ct.CronExpression);
         Test.stopTest();
    }
    private static void createBaseInfo(){
          ///创建用户
         Id ldcProfile = [Select Id From Profile Where Name ='系统管理员' or Name='System Administrator'].Id;
         User u1 = new User( Alias = 'samLdc1', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile, 
                         Country = 'United States',
                         IsActive = true,
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='客户服务中心(工程部)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123456',
                         Username = 'Matldc1@test.com.maike' ,
                         AreaCode__c = 'C1234567890');
        
        insert u1;
        
        ///创建销售区域预算执行明细
        SalesAreaBudgetExecSheet__c sa = new SalesAreaBudgetExecSheet__c();
        sa.RegionCoding__c = 'C1234567890';
        insert sa;

    }
}